<?php
class Zendhlt_View_Helper_EditorElement extends Zend_View_Helper_FormElement {
	
	public function editorElement($name, $options = null, $width = '80%', $height = '350') {
		//1. Nhung tap tin ckeditor vao file chay
		require_once (PUBLIC_REQUIRED_PATH . "/scripts/ckeditor/ckeditor.php") ;
		
		//2. Khai bao duong dan URL den thu muc ckeditor
		$sBasePath = SCRIPTS_URL . '/ckeditor/';
		
		//3. Khoi tao doi tuong CKeditor
		$oCKeditor = new CKEditor($sBasePath) ;
		
		//4. Thiet lap duong den cho thuong BasePath
		$oCKeditor->BasePath = $sBasePath;
		
		//Thay doi kich thuoc cua Editor
		$config = array(
							'width'    => $width,
			            	'height'   => $height,
			      	  );

		$oCKeditor->config = $config;
		
		$oCKeditor->config['filebrowserBrowseUrl']       = EDITOR_URL . '/filemanager/index.html?langCode=vi';
		$oCKeditor->config['filebrowserImageBrowseUrl']  = EDITOR_URL . '/filemanager/index.html?langCode=vi&type=Images';
		$oCKeditor->config['filebrowserFlashBrowseUrl']  = EDITOR_URL . '/filemanager/index.html?langCode=vi&type=Flash';
		$oCKeditor->config['filebrowserUploadUrl']       = EDITOR_URL . '/filemanager/connectors/php/upload.php?type=File';
		$oCKeditor->config['filebrowserImageUploadUrl']  = EDITOR_URL . '/filemanager/connectors/php/upload.php?type=Image';
		$oCKeditor->config['filebrowserFlashUploadUrl']  = EDITOR_URL . '/filemanager/connectors/php/upload.php?type=Flash';
		$oCKeditor->config['language'] = 'vi';
		if (isset($options['toolbar'])){
			$oCKeditor->config['toolbar_Full'] = $options['toolbar'];
		}
		
		//5. Tao CKeditor
		$oCKeditor->replace($name);
	}
}